<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>运行时配置</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="opcache.installation.html">安装</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="opcache.resources.html">资源类型</a></div>
 <div class="up"><a href="opcache.setup.html">安装／配置</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="opcache.configuration" class="sect1">
 <h2 class="title">运行时配置</h2>
 <p class="simpara">
这些函数的行为受 <var class="filename">php.ini</var> 中的设置影响。
</p>
 <p class="para">
  <table class="doctable table">
   <caption><strong>OPcache configuration options</strong></caption>
   
    <thead>
     <tr>
      <th>名字</th>
      <th>默认</th>
      <th>可修改范围</th>
      <th>更新日志</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.enable" class="link">opcache.enable</a></td>
      <td>&quot;1&quot;</td>
      <td>PHP_INI_ALL</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.enable-cli" class="link">opcache.enable_cli</a></td>
      <td>&quot;0&quot;</td>
      <td>PHP_INI_SYSTEM</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.memory-consumption" class="link">opcache.memory_consumption</a></td>
      <td>&quot;64&quot;</td>
      <td>PHP_INI_SYSTEM</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.interned-strings-buffer" class="link">opcache.interned_strings_buffer</a></td>
      <td>&quot;4&quot;</td>
      <td>PHP_INI_SYSTEM</td>
      <td>Available since PHP 5.3.0.</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.max-accelerated-files" class="link">opcache.max_accelerated_files</a></td>
      <td>&quot;2000&quot;</td>
      <td>PHP_INI_SYSTEM</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.max-wasted-percentage" class="link">opcache.max_wasted_percentage</a></td>
      <td>&quot;5&quot;</td>
      <td>PHP_INI_SYSTEM</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.use-cwd" class="link">opcache.use_cwd</a></td>
      <td>&quot;1&quot;</td>
      <td>PHP_INI_SYSTEM</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.validate-timestamps" class="link">opcache.validate_timestamps</a></td>
      <td>&quot;1&quot;</td>
      <td>PHP_INI_ALL</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.revalidate-freq" class="link">opcache.revalidate_freq</a></td>
      <td>&quot;2&quot;</td>
      <td>PHP_INI_ALL</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.revalidate-path" class="link">opcache.revalidate_path</a></td>
      <td>&quot;0&quot;</td>
      <td>PHP_INI_ALL</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.save-comments" class="link">opcache.save_comments</a></td>
      <td>&quot;1&quot;</td>
      <td>PHP_INI_SYSTEM</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.load-comments" class="link">opcache.load_comments</a></td>
      <td>&quot;1&quot;</td>
      <td>PHP_INI_ALL</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.fast-shutdown" class="link">opcache.fast_shutdown</a></td>
      <td>&quot;0&quot;</td>
      <td>PHP_INI_SYSTEM</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.enable-file-override" class="link">opcache.enable_file_override</a></td>
      <td>&quot;0&quot;</td>
      <td>PHP_INI_SYSTEM</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.optimization-level" class="link">opcache.optimization_level</a></td>
      <td>&quot;0xffffffff&quot;</td>
      <td>PHP_INI_SYSTEM</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.inherited-hack" class="link">opcache.inherited_hack</a></td>
      <td>&quot;1&quot;</td>
      <td>PHP_INI_SYSTEM</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.dups-fix" class="link">opcache.dups_fix</a></td>
      <td>&quot;0&quot;</td>
      <td>PHP_INI_ALL</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.blacklist-filename" class="link">opcache.blacklist_filename</a></td>
      <td>&quot;&quot;</td>
      <td>PHP_INI_SYSTEM</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.max-file-size" class="link">opcache.max_file_size</a></td>
      <td>&quot;0&quot;</td>
      <td>PHP_INI_SYSTEM</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.consistency-checks" class="link">opcache.consistency_checks</a></td>
      <td>&quot;0&quot;</td>
      <td>PHP_INI_ALL</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.force-restart-timeout" class="link">opcache.force_restart_timeout</a></td>
      <td>&quot;180&quot;</td>
      <td>PHP_INI_SYSTEM</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.error-log" class="link">opcache.error_log</a></td>
      <td>&quot;&quot;</td>
      <td>PHP_INI_SYSTEM</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.log-verbosity-level" class="link">opcache.log_verbosity_level</a></td>
      <td>&quot;1&quot;</td>
      <td>PHP_INI_SYSTEM</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.preferred-memory-model" class="link">opcache.preferred_memory_model</a></td>
      <td>&quot;&quot;</td>
      <td>PHP_INI_SYSTEM</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.protect-memory" class="link">opcache.protect_memory</a></td>
      <td>&quot;0&quot;</td>
      <td>PHP_INI_SYSTEM</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="opcache.configuration.html#ini.opcache.mmap-base" class="link">opcache.mmap_base</a></td>
      <td><strong><code>NULL</code></strong></td>
      <td>PHP_INI_SYSTEM</td>
      <td class="empty">&nbsp;</td>
     </tr>

    </tbody>
   
  </table>

  有关 PHP_INI_* 样式的更多详情与定义，见 <a href="configuration.changes.modes.html" class="xref">配置可被设定范围</a>。
 </p>
 
 <p class="para">这是配置指令的简短说明。</p>
 
 <p class="para">
  <dl>

   
    <dt id="ini.opcache.enable">
     <em><code class="parameter">opcache.enable</code></em>
     <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span>
    </dt>

    <dd>

     <p class="para">
      Enables the opcode cache. When disabled, code is not optimised and
      cached.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.enable-cli">
     <em><code class="parameter">opcache.enable_cli</code></em>
     <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span>
    </dt>

    <dd>

     <p class="para">
      Enables the opcode cache for the CLI version of PHP. This is mostly
      useful for testing and debugging.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.memory-consumption">
     <em><code class="parameter">opcache.memory_consumption</code></em>
     <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>
    </dt>

    <dd>

     <p class="para">
      The size of the shared memory storage used by OPcache, in megabytes.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.interned-strings-buffer">
     <em><code class="parameter">opcache.interned_strings_buffer</code></em>
     <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>
    </dt>

    <dd>

     <p class="para">
      The amount of memory used to store interned strings, in megabytes. This
      configuration directive is ignored in PHP &lt; 5.3.0.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.max-accelerated-files">
     <em><code class="parameter">opcache.max_accelerated_files</code></em>
     <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>
    </dt>

    <dd>

     <p class="para">
      The maximum number of keys (and therefore scripts) in the OPcache hash
      table. The actual value used will be the first number in the set of
      prime numbers
      <em>{ 223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987 }</em>
      that is bigger than the configured value. Only numbers between 200 and
      100000 are allowed.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.max-wasted-percentage">
     <em><code class="parameter">opcache.max_wasted_percentage</code></em>
     <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>
    </dt>

    <dd>

     <p class="para">
      The maximum percentage of wasted memory that is allowed before a restart
      is scheduled.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.use-cwd">
     <em><code class="parameter">opcache.use_cwd</code></em>
     <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span>
    </dt>

    <dd>

     <p class="para">
      If enabled, OPcache appends the current working directory to the script
      key, thereby eliminating possible collisions between files with the same
      base name. Disabling this directive improves performance, but may break
      existing applications.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.validate-timestamps">
     <em><code class="parameter">opcache.validate_timestamps</code></em>
     <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span>
    </dt>

    <dd>

     <p class="para">
      If enabled, OPcache will check for updated scripts every
      <a href="opcache.configuration.html#ini.opcache.revalidate-freq" class="link">opcache.revalidate_freq</a>
      seconds. When this directive is disabled, you must reset OPcache
      manually via <span class="function"><a href="function.opcache-reset.html" class="function">opcache_reset()</a></span>,
      <span class="function"><a href="function.opcache-invalidate.html" class="function">opcache_invalidate()</a></span> or by restarting the Web server
      for changes to the filesystem to take effect.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.revalidate-freq">
     <em><code class="parameter">opcache.revalidate_freq</code></em>
     <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>
    </dt>

    <dd>

     <p class="para">
      How often to check script timestamps for updates, in seconds.
      <em>0</em> will result in OPcache checking for updates on
      every request.
     </p>
     <p class="para">
      This configuration directive is ignored if
      <a href="opcache.configuration.html#ini.opcache.validate-timestamps" class="link">opcache.validate_timestamps</a>
      if disabled.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.revalidate-path">
     <em><code class="parameter">opcache.revalidate_path</code></em>
     <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span>
    </dt>

    <dd>

     <p class="para">
      If disabled, existing cached files using the same
      <a href="ini.core.html#ini.include-path" class="link">include_path</a> will be reused.
      Thus, if a file with the same name is elsewhere in the include_path, it
      won&#039;t be found.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.save-comments">
     <em><code class="parameter">opcache.save_comments</code></em>
     <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span>
    </dt>

    <dd>

     <p class="para">
      If disabled, all documentation comments will be discarded from the
      opcode cache to reduce the size of the optimised code. Disabling this
      configuration directive may break applications and frameworks that rely
      on comment parsing for annotations, including Doctrine, Zend Framework 2
      and PHPUnit.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.load-comments">
     <em><code class="parameter">opcache.load_comments</code></em>
     <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span>
    </dt>

    <dd>

     <p class="para">
      If disabled, documentation comments won&#039;t be loaded from the opcode
      cache even if they exist. This can be used with
      <a href="opcache.configuration.html#ini.opcache.save-comments" class="link">opcache.save_comments</a>
      to only load comments for applications that require them.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.fast-shutdown">
     <em><code class="parameter">opcache.fast_shutdown</code></em>
     <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span>
    </dt>

    <dd>

     <p class="para">
      If enabled, a fast shutdown sequence is used that doesn&#039;t free each
      allocated block, but relies on the Zend Engine memory manager to
      deallocate the entire set of request variables en masse.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.enable-file-override">
     <em><code class="parameter">opcache.enable_file_override</code></em>
     <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span>
    </dt>

    <dd>

     <p class="para">
      When enabled, the opcode cache will be checked for whether a file has
      already been cached when <span class="function"><a href="function.file-exists.html" class="function">file_exists()</a></span>,
      <span class="function"><a href="function.is-file.html" class="function">is_file()</a></span> and <span class="function"><a href="function.is-readable.html" class="function">is_readable()</a></span> are
      called. This may increase performance in applications that check the
      existence and readability of PHP scripts, but risks returning stale data
      if 
      <a href="opcache.configuration.html#ini.opcache.validate-timestamps" class="link">opcache.validate_timestamps</a>
      is disabled.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.optimization-level">
     <em><code class="parameter">opcache.optimization_level</code></em>
     <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>
    </dt>

    <dd>

     <p class="para">
      A bitmask that controls which optimisation passes are executed.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.inherited-hack">
     <em><code class="parameter">opcache.inherited_hack</code></em>
     <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span>
    </dt>

    <dd>

     <p class="para">
      In PHP &lt; 5.3, OPcache stores the places where
      <a href="internals2.opcodes.declare-class.html" class="link">DECLARE_CLASS</a>
      opcodes used inheritance; when the file is loaded, OPcache then tries to
      bind the inherited classes using the current environment. The problem is
      that while the DECLARE_CLASS opcode may not be needed for the current
      script, if the script requires that the opcode be defined, it may not
      run.
     </p>
     <p class="para">
      This configuration directive is ignored in PHP 5.3 and later.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.dups-fix">
     <em><code class="parameter">opcache.dups_fix</code></em>
     <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span>
    </dt>

    <dd>

     <p class="para">
      This hack should only be enabled to work around &quot;Cannot redeclare class&quot;
      errors.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.blacklist-filename">
     <em><code class="parameter">opcache.blacklist_filename</code></em>
     <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
    </dt>

    <dd>

     <p class="para">
      The location of the OPcache blacklist file. A blacklist file is a text
      file containing the names of files that should not be accelerated, one
      per line. Wildcards are allowed, and prefixes can also be provided.
      Lines starting with a semi-colon are ignored as comments.
     </p>
     <p class="para">
      A simple blacklist file might look as follows:
     </p>
     <div class="informalexample">
      <div class="example-contents">
<div class="cdata"><pre>
; Matches a specific file.
/var/www/broken.php
; A prefix that matches all files starting with x.
/var/www/x
; A wildcard match.
/var/www/*-broken.php
</pre></div>
      </div>

     </div>
    </dd>

   
   
    <dt id="ini.opcache.max-file-size">
     <em><code class="parameter">opcache.max_file_size</code></em>
     <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>
    </dt>

    <dd>

     <p class="para">
      The maximum file size that will be cached, in bytes. If this is
      <em>0</em>, all files will be cached.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.consistency-checks">
     <em><code class="parameter">opcache.consistency_checks</code></em>
     <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>
    </dt>

    <dd>

     <p class="para">
      If non-zero, OPcache will verify the cache checksum every N requests,
      where N is the value of this configuration directive. This should only
      be enabled when debugging, as it will impair performance.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.force-restart-timeout">
     <em><code class="parameter">opcache.force_restart_timeout</code></em>
     <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>
    </dt>

    <dd>

     <p class="para">
      The length of time to wait for a scheduled restart to begin if the cache
      isn&#039;t active, in seconds. If the timeout is hit, then OPcache assumes
      that something is wrong and will kill the processes holding locks on the
      cache to permit a restart.
     </p>
     <p class="para">
      If
      <a href="opcache.configuration.html#ini.opcache.log-verbosity-level" class="link">opcache.log_verbosity_level</a>
      is set to 3 or above, an error will be recorded in the error log when
      this occurs.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.error-log">
     <em><code class="parameter">opcache.error_log</code></em>
     <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
    </dt>

    <dd>

     <p class="para">
      The error log for OPcache errors. An empty string is treated the same as
      <em>stderr</em>, and will result in logs being sent to
      standard error (which will be the Web server error log in most cases).
     </p>
    </dd>

   
   
    <dt id="ini.opcache.log-verbosity-level">
     <em><code class="parameter">opcache.log_verbosity_level</code></em>
     <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>
    </dt>

    <dd>

     <p class="para">
      The log verbosity level. By default, only fatal errors (level 0) and
      errors (level 1) are logged. Other levels available are warnings (level
      2), information messages (level 3) and debug messages (level 4).
     </p>
    </dd>

   
   
    <dt id="ini.opcache.preferred-memory-model">
     <em><code class="parameter">opcache.preferred_memory_model</code></em>
     <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
    </dt>

    <dd>

     <p class="para">
      The preferred memory model for OPcache to use. If left empty, OPcache
      will choose the most appropriate model, which is the correct behaviour
      in virtually all cases.
     </p>
     <p class="para">
      Possible values include <em>mmap</em>, <em>shm</em>,
      <em>posix</em> and <em>win32</em>.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.protect-memory">
     <em><code class="parameter">opcache.protect_memory</code></em>
     <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span>
    </dt>

    <dd>

     <p class="para">
      Protects shared memory from unexpected writes while executing scripts.
      This is useful for internal debugging only.
     </p>
    </dd>

   
   
    <dt id="ini.opcache.mmap-base">
     <em><code class="parameter">opcache.mmap_base</code></em>
     <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
    </dt>

    <dd>

     <p class="para">
      The base used for shared memory segments on Windows. All PHP processes
      have to map shared memory into the same address space. Using this
      directive allows &quot;Unable to reattach to base address&quot; errors to be
      fixed.
     </p>
    </dd>

   
  </dl>

 </p>
</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="opcache.installation.html">安装</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="opcache.resources.html">资源类型</a></div>
 <div class="up"><a href="opcache.setup.html">安装／配置</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
